<template>
  <div :class="'course-item '+(viewType == 'two'?'two':'')">
    <div class="course-img">
      <img v-lazy="img_url+banner">
      <p class="course-img-team" v-if="isGroup==1">拼团</p>
    </div>
    <div class="course-content">
      <h4 class="course-title shuang wordBreak">{{title}}</h4>
      <div class="course-bottom">
        <!--音频标签-->
        <p class="course-price" >
          <i :class="(goodtype == 1?'tag-video':'tag-audio')"></i>{{ price=="0.00" ? "免费" : (price.indexOf("￥")>-1?price:"￥"+price) }}
        </p>
        <p class="stu-num" v-if="time==''">
          {{studyCount}}人在学
        </p>
        <p class="stu-num" v-if="time!=''">{{time}}</p>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["img_url"])
  },
  props: {
    id: {
      type: Number,
      default: 0
    },
    viewType: {
      type: String,
      default: ""
    },
    banner: {
      type: String,
      default: ""
    },
    title: {
      type: String,
      default: ""
    },
    time: {
      type: String,
      default: ""
    },
    studyCount: {
      type: Number,
      default: 0
    },
    price: {
      type: String,
      default: ""
    },
    // 1 视频 2 音频
    goodtype: {
      type: Number,
      default: 1
    },
    isGroup: {
      type: Number,
      default: 0
    }
  },
  created() {
    // // alert(this.viewType);
    //   console.log(this.viewType,this.id,"hah");
  },
  methods: {}
};
</script>
<style scoped lang="scss">
.course-item {
  float: left;
  width: 1.7rem;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  // 1行1个
  &.two {
    float: none;
    width: auto;
    display: flex;
    flex-direction: row;
    .course-img img {
      width: 1.25rem;
      height: 0.7rem;
      border-radius: 0.02rem;
    }
    .course-content {
      width: 1.96rem;
      height: 0.7rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-left: 0.06rem;
      padding: 0;
    }
  }

  .course-img {
    position: relative;
    img {
      width: 1.7rem;
      height: 0.95rem;
      border-radius: 0.02rem 0.02rem 0 0;
    }
    &-team {
      position: absolute;
      top: 0.06rem;
      right: 0.06rem;
      width: 0.3rem;
      height: 0.16rem;
      line-height: 0.14rem;
      border-radius: 0.1rem;
      text-align: center;
      color: #ffffff;
      font-size: 0.1rem;
      background-color: #f56c6c;
      border: 1px solid #fff;
    }
  }

  .course-content {
    width: 1.7rem;
    padding: 10px 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    border-radius: 0 0 0.02rem 0.02rem;
  }
  .course-title {
    color: #303133;
    font-size: 0.16rem;
    height: 0.44rem;
    line-height: 0.22rem;
  }
  .course-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.12rem;
    // 多少人在学、时间
    .stu-num {
      font-size: 0.12rem;
      color: #c0c4cc;
      line-height: 0.17rem;
      // padding-left: .16rem;
      // position: relative;
    }
    .course-price {
      font-size: 0.14rem;
      color: #0486fe;
      line-height: 0.17rem;
      i {
        display: inline-block;
        width: 0.12rem;
        height: 0.12rem;
        vertical-align: sub;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        margin-right: 0.02rem;
        margin-bottom: .02rem;
      }
    }
  }
}

.course-item i.tag-audio {
  background: url("../../assets/images/audio-icon.png") no-repeat center/contain;
}

.course-item i.tag-video {
  background: url("../../assets/images/video-icon.png") no-repeat center/contain;
}
</style>


